package com.woniuxy.joylifeshop.configuration;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.PathMatchConfigurer;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class CenterConfig implements WebMvcConfigurer {
    @Override
    public void configurePathMatch(PathMatchConfigurer configurer) {
        configurer.setUseSuffixPatternMatch(false);
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**")
                .addResourceLocations("classpath:/static/")
                .addResourceLocations("classpath:/public/")
                .addResourceLocations("classpath:/resources/");

    }

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        //主页
        registry.addViewController("/index").setViewName("index.html");
        registry.addViewController("/").setViewName("/login-1.html");
        //404
        registry.addViewController("/error/404.html").setViewName("/error/404.html");
        //映射
        registry.addViewController("/page/orderManager.html").setViewName("/page/orderManager.html");
        registry.addViewController("/page/repository.html").setViewName("/page/repository.html");
        registry.addViewController("/page/commodityManager.html").setViewName("/page/commodityManager.html");
        registry.addViewController("/page/current.html").setViewName("/page/current.html");
        registry.addViewController("/page/turnover.html").setViewName("/page/turnover.html");
        registry.addViewController("/page/income.html").setViewName("/page/income.html");
        registry.addViewController("/page/withdraw.html").setViewName("/page/withdraw.html");
        registry.addViewController("/page/welcome-1.html").setViewName("/page/welcome-1.html");
        registry.addViewController("/page/commodityPicture.html").setViewName("/page/commodityPicture.html");
        //子映射
        registry.addViewController("/page/table/editCommodity.html").setViewName("/page/table/editCommodity.html");
        registry.addViewController("/page/table/editRepository.html").setViewName("/page/table/editRepository.html");
        registry.addViewController("/page/table/editWithdraw.html").setViewName("/page/table/editWithdraw.html");
        registry.addViewController("/page/table/addCommodity.html").setViewName("/page/table/addCommodity.html");
        registry.addViewController("/page/table/editPicture.html").setViewName("/page/table/editPicture.html");



    }
}
